package com.sckj.springboot.listener;

import com.sckj.springboot.entity.User;
import com.sckj.springboot.event.MyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class MyEventListener implements ApplicationListener<MyEvent> {

    @Override
    public void onApplicationEvent(MyEvent event) {
        //把事件中的信息获取到
        User user = event.getUser();
        //处理事件
        System.out.println("username: "+ user.getName());
        System.out.println("password: "+user.getPassword());
    }
}
